home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / fontutil.6 / fontutil / fontutils-0.6 / include / list.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-13  |  1.6 KB  |  56 lines

  1. /* list.h: simple list (represented as arrays) manipulation.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef LIST_H
  20. #define LIST_H
  21.  
  22. #include "types.h"
  23.  
  24.  
  25. typedef struct
  26. {
  27.   address *list;
  28.   unsigned size;
  29. } list_type;
  30.  
  31. /* The size of the list L.  */
  32. #define LIST_SIZE(l) ((l).size)
  33.  
  34. /* The address of the array of data.  */
  35. #define LIST_DATA(l) ((l).list)
  36.  
  37. /* Get the contents of the element at position INDEX in L.  */
  38. #define LIST_ELT(l, index) LIST_DATA (l)[index]
  39.  
  40. /* Get the last list element.  */
  41. #define LIST_LAST_ELT(l) LIST_ELT (l, LIST_SIZE (l) - 1)
  42.  
  43.  
  44. /* Constructor/destructor.  */
  45. extern list_type list_init (void);
  46. extern void list_free (list_type *);
  47.  
  48. /* Returns a pointer to ELEMENT_SIZE bytes of memory allocated for the
  49.    new element.  */
  50. extern address list_append (list_type *, unsigned element_size);
  51.  
  52. /* An abbreviation for the usual case.  */
  53. #define LIST_TAPPEND(l_ptr, type) list_append (l_ptr, sizeof (type))
  54.  
  55. #endif /* not LIST_H */
  56.